package com.sansung;


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIManager;

import org.apache.log4j.Logger;
import org.apache.log4j.MDC;
import org.jdesktop.swingx.JXStatusBar;
import org.jvnet.substance.SubstanceLookAndFeel;

import com.sansung.util.MyUtil;

public class MainFrame extends JFrame implements ActionListener{
       /**
	 * uuid
	 */
	private static final long serialVersionUID = 3674774952739961298L;
	
	private static Logger logger = Logger.getLogger(MainFrame.class);
	
	public MainFrame(){
		try {
			this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			this.setSize(980, 600);
			this.setTitle("SANSUNG管理系统V1.0");
			this.setIconImage(new ImageIcon(this.getClass()
   				.getResource("resources/images/logo.png"))
   				.getImage());
			setLocationRelativeTo(null);
			if (!(UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel)) {
				UIManager
				.setLookAndFeel("org.jvnet.substance.skin.SubstanceOfficeBlue2007LookAndFeel");
				SubstanceLookAndFeel.setToUseConstantThemesOnDialogs(true);
			}
			//状态条（版权信息）
			JXStatusBar statusBar=new JXStatusBar();
			JLabel copyright=new JLabel("Copyright@2013,Sansung版权所有");
			JPanel southPanel = new JPanel();
			southPanel.setPreferredSize(new Dimension(this.getWidth(), 22));
			southPanel.add(copyright, BorderLayout.CENTER);
			statusBar.add(southPanel);
			this.add(statusBar,BorderLayout.SOUTH);
			//菜单
    	    JMenuBar aMenuBar = new JMenuBar();
    	    JMenu aMenu = new JMenu("系统");
    	    JMenu bMenu = new JMenu("原料");
    	    JMenu cMenu = new JMenu("车间生产");
    	    JMenu dMenu = new JMenu("送染");
    	    JMenu eMenu = new JMenu("成品");
    	    JMenu fMenu = new JMenu("客户订单");
    	    JMenu gMenu = new JMenu("报表管理");
    	    JMenu hMenu = new JMenu("人事管理");
    	    JMenu iMenu = new JMenu("系统管理");
    	    JMenuItem aaMenuItem = new JMenuItem("产品信息");
    	    JMenuItem abMenuItem = new JMenuItem("锁定界面");
    	    JMenuItem baMenuItem = new JMenuItem("原料入库");
    	    JMenuItem bbMenuItem = new JMenuItem("原料状态");
    	    JMenuItem caMenuItem = new JMenuItem("车间");
    	    JMenuItem daMenuItem = new JMenuItem("过程跟踪");
    	    JMenuItem eaMenuItem = new JMenuItem("成品记录");
    	    JMenuItem faMenuItem = new JMenuItem("订单状态");
    	    JMenuItem fbMenuItem = new JMenuItem("原料状态");
    	    JMenuItem gaMenuItem = new JMenuItem("原料");
    	    JMenuItem gbMenuItem = new JMenuItem("车间");
    	    JMenuItem gcMenuItem = new JMenuItem("送染");
    	    JMenuItem gdMenuItem = new JMenuItem("成品");
    	    JMenuItem geMenuItem = new JMenuItem("客户订单");
    	    JMenuItem haMenuItem = new JMenuItem("管理");
    	    JMenuItem iaMenuItem = new JMenuItem("权限设置");
    	    JMenuItem ibMenuItem = new JMenuItem("系统日志");
    	    JMenuItem icMenuItem = new JMenuItem("数据维护");
    	    JMenuItem idMenuItem = new JMenuItem("在线用户");
    	    JMenuItem ieMenuItem = new JMenuItem("退出登录");
    	    ieMenuItem.setIcon(MyUtil.getImageIcon("ext/house_go.png"));
    	    aMenuBar.add(aMenu);
    	    aMenuBar.add(bMenu);
    	    aMenuBar.add(cMenu);
    	    aMenuBar.add(dMenu);
    	    aMenuBar.add(eMenu);
    	    aMenuBar.add(fMenu);
    	    aMenuBar.add(gMenu);
    	    aMenuBar.add(hMenu);
    	    aMenuBar.add(iMenu);
    	    aMenu.add(aaMenuItem);
    	    aMenu.add(abMenuItem);
    	    bMenu.add(baMenuItem);
    	    bMenu.add(bbMenuItem);
    	    cMenu.add(caMenuItem);
    	    dMenu.add(daMenuItem);
    	    eMenu.add(eaMenuItem);
    	    fMenu.add(faMenuItem);
    	    fMenu.add(fbMenuItem);
    	    gMenu.add(gaMenuItem);
    	    gMenu.add(gbMenuItem);
    	    gMenu.add(gcMenuItem);
    	    gMenu.add(gdMenuItem);
    	    gMenu.add(geMenuItem);
    	    hMenu.add(haMenuItem);
    	    iMenu.add(iaMenuItem);
    	    iMenu.add(ibMenuItem);
    	    iMenu.add(icMenuItem);
    	    iMenu.add(idMenuItem);
    	    iMenu.add(ieMenuItem);
    	    aaMenuItem.addActionListener(this);
    	    abMenuItem.addActionListener(this);
    	    baMenuItem.addActionListener(this);
    	    bbMenuItem.addActionListener(this);
    	    ieMenuItem.addActionListener(this);
//    	    setJMenuBar(aMenuBar);//默认菜单（采用下面的放在pane中加背景图片）
    	    JPanel menuPanel=new JPanel()
    	    {
				private static final long serialVersionUID = 5645447776016533721L;
				@Override
				protected void paintComponent(Graphics g) {
					// TODO Auto-generated method stub
					Image img = MyUtil.getImageIcon("unicloudlogo2.png").getImage();
					g.drawImage(img, 0, 0, 2000, 50, null);
			}};
			menuPanel.add(aMenuBar);
			menuPanel.setBackground(Color.green);
			FlowLayout layout = new FlowLayout(FlowLayout.RIGHT, 2,30);
			menuPanel.setLayout(layout);
			menuPanel.setPreferredSize(new Dimension(this.getWidth(),50));
			getContentPane().add(menuPanel,BorderLayout.NORTH);
    	    
			JScrollPane mainScrollPanel=new JScrollPane();
//			mainPanel.setBackground(Color.red);
			this.getContentPane().add(mainScrollPanel,BorderLayout.CENTER);
		} catch (Exception e) {
			logger.error(e);
		}
	}
    	   
	  public static void main(String args[]){
		   JFrame frame = new MainFrame();
		   frame.setVisible(true);
	  }
	  
	  public void start(){
		  JFrame frame = new MainFrame();
	   	  frame.setVisible(true);
	  }

	@Override
	public void actionPerformed(ActionEvent e) {
		
	};
}
